package com.wxtt.android.animation;

import android.os.Build;
import android.view.View;
import android.view.ViewPropertyAnimator;

/**
 * 说明：动画工具类
 * <p/>
 * 作者：fanly
 * <p/>
 * 时间：2016/1/26 0:08
 * <p/>
 * 版本：verson 1.0
 */
public class AnimatorUtils {

    private AnimatorUtils(){}

    public static void viewPropertyStartCompat(ViewPropertyAnimator animator) {
        if (Build.VERSION.SDK_INT >= 14) {
            animator.start();
        }
    }

    public static void animateHeart(View imageLovedOn, View imageLovedOff, boolean on) {
        imageLovedOn.setVisibility(View.VISIBLE);
        imageLovedOff.setVisibility(View.VISIBLE);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
            viewPropertyStartCompat(imageLovedOff.animate().scaleX(on ? 0 : 1).scaleY(on ? 0 : 1).alpha(on ? 0 : 1));
            viewPropertyStartCompat(imageLovedOn.animate().scaleX(on ? 1 : 0).scaleY(on ? 1 : 0).alpha(on ? 1 : 0));
        }
    }

}
